﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LibraryO2S;

public partial class Administrator_StatisticCard : System.Web.UI.Page
{
    Dataprocess data = new Dataprocess();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            rptData.DataSource = LoadData();
            rptData.DataBind();

        }
    }

    public DataTable LoadData()
    {
        DataTable table = new DataTable();
        DataColumn dtColumn = new DataColumn("Tong");
        table.Columns.Add(dtColumn);
        DataColumn dtColumn1 = new DataColumn("Name");
        table.Columns.Add(dtColumn1);
        DataColumn dtColumn2 = new DataColumn("SuDung");
        table.Columns.Add(dtColumn2);
        DataColumn dtColumn3 = new DataColumn("ChuaSuDung");
        table.Columns.Add(dtColumn3);

        int tong = 0;
        int cardother = 0;

        DataTable dbtypecard = data.allSystem("select * from tblCardType order by Id ");
        foreach (DataRow dr in dbtypecard.Rows)
        {
            int totalcard = 0;
            int cardnull = 0;
            int card = 0;
            

            string code = dr["Code"].ToString();
            string name = dr["Name"].ToString();
            DataTable dbcard = data.allSystem("select * from tblCard where CardTypeCode="+code+" ");
            foreach (DataRow drcard in dbcard.Rows)
            {
                totalcard += 1;
                
            }
            DataTable dbnullcard = data.allSystem("select * from tblCard where CardTypeCode=" + code + " and IsRelease= 1 ");
            foreach (DataRow drdbnullcard in dbnullcard.Rows)
            {
                cardnull += 1;
            }
            //DataTable dbcardother = data.allSystem("select * from tblCard order by Id");
            //foreach (DataRow drother in dbcardother.Rows)
            //{
            //    cardother += 1;
            //}



            tong += totalcard;

            card = totalcard - cardnull;

            DataRow dtRow = table.NewRow();
            dtRow[0] = name;
            dtRow[1] = totalcard;
            dtRow[2] = cardnull;
            dtRow[3] = card;
            table.Rows.Add(dtRow);

           // lblother.Text = "" + cardother;

        }
        int c = tong - cardother;
        lbltotle.Text =""+ tong;
       
        return table;
    }

    protected void btnAdnew1_Click(object sender, EventArgs e)
    {
        Response.Redirect("BannerAdd.aspx");
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {

    }
    protected void btnUpdateDisplayOrder_Click(object sender, EventArgs e)
    {
        rptData.DataSource = LoadData();
        rptData.DataBind();
    }
}